package com.zhb.core.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;

/**
 * @Title: RedisConfig.java
 * @Package com.zzh.sys.configuration
 * @Description: redis整合spring的核心配置
 * @author zhb
 * @date 2016年3月6日 下午8:03:19
 * @version V1.0
 */
@Configuration
public class RedisConfig {
	/**
	 * @Title: redisTemplate
	 * @Description: 操作模板
	 * @return: RedisTemplate<Object,Object>
	 * @param: @return
	 * @author: zhb
	 * @throws 2016年3月6日下午8:11:33
	 */
	@Autowired
	JedisConnectionFactory jedisConnectionFactory;

	public @Bean RedisTemplate<Object, Object> redisTemplate() {
		RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<>();
		redisTemplate.setConnectionFactory(jedisConnectionFactory);
		return redisTemplate;
	}

	public @Bean StringRedisTemplate stringRedisTemplate() {
		return new StringRedisTemplate(jedisConnectionFactory);
	}
}
